<!--导航区-->
<nav class="navbar navbar-expand-md navbar-dark fixed-top bg-dark">
  <%= link_to "JackLovel's blog", root_path, class: "navbar-brand" %>
  <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarCollapse" aria-controls="navbarCollapse" aria-expanded="false" aria-label="Toggle navigation">
    <span class="navbar-toggler-icon"></span>
  </button>
  <div class="collapse navbar-collapse" id="navbarCollapse">
    <ul class="navbar-nav mr-auto">
      <li class="nav-item active">
        <%= link_to "首页", root_path, class: "nav-link" %>
      </li>
      <li class="nav-item">
        <%= link_to "新建文章", new_article_path, class: "nav-link" %>
      </li>

      <% if admin_user? %>
        <li class="nav-item">
          <%= link_to "管理", admin_root_path, class: "nav-link" %>
        </li>
      <% end %>

      <% if current_user %>
        <li class="nav-item">
          <%= link_to "个人空间", current_user, class: "nav-link" %>
        </li>
        <li class="nav-item">
          <%= link_to "登出", logout_path, method: "delete", class: "nav-link" %>
        </li>
      <% else %>
        <li class="nav-item">
          <%= link_to "登录", login_path, class: "nav-link" %>
        </li>
        <li class="nav-item">
          <%= link_to "注册", signup_path, class: "nav-link" %>
        </li>
      <% end %>
    </ul>

    <%= form_tag root_path, :class => "form-inline mt-2 mt-md-0", method: :get do %>
      <%= text_field_tag :q, params[:q], placeholder: "请输入关键字", class: "form-control mr-sm-2" %>
      <%= submit_tag "搜索", name: nil, class: "btn btn-outline-success my-2 my-sm-0" %>
    <% end %>
  </div>
</nav>
